package gui.clock;

import java.awt.event.ActionListener;
import javax.swing.Timer;
import simulation.SimEngine;
import common.Constants;
import common.EarthSimSettings;

public abstract class AbstractClock implements ActionListener {
  protected EarthSimSettings settings = EarthSimSettings.getInstance();
  protected Timer dateTimeClock;
  protected long simTimeStep; //in milliseconds
  protected float sunDegStep; //derived from simTimeStep to update the display of the sun in the earth panel
  
  public AbstractClock() {
    dateTimeClock = new Timer(Constants.DEFAULT_DISPLAY_RATE, this);
    setSimTimeStep(Constants.DEFAULT_SIM_TIME_STEP);    
  }
  
  protected void setSimTimeStep(int minutes) {
    simTimeStep = minutes * 60 * 1000;
    sunDegStep = Constants.DEG_PER_MIN * (float)minutes;
  }
  
  public void adjustDisplayRate(int newRate) {
    dateTimeClock.setDelay(newRate);
  }
  
  public abstract void start();
  
  public abstract void pause();
  
  public abstract void reset();
}
